function ConfirmOk(URL, msg) { var Ok = confirm(msg); if (Ok == true) { document.location.href = URL; } } function OkReturnUrl(URL, msg) { alert(msg); document.location.href = URL; } // calculate the ASCII code of the given character function CalcKeyCode(aChar) { var character = aChar.substring(0,1); var code = aChar.charCodeAt(0); return code; } function checkNumber(val) { var strPass = val.value; var strLength = strPass.length; var lchar = val.value.charAt((strLength) - 1); var cCode = CalcKeyCode(lchar); /* Check if the keyed in character is a number do you want alphabetic UPPERCASE only ? or lower case only just check their respective codes and replace the 48 and 57 */ if (cCode < 48 || cCode > 57 ) { var myNumber = val.value.substring(0, (strLength) - 1); val.value = myNumber; } return false; } function Message(msg) { alert(msg); } function DisplayDetails(idd) { document.getElementById(idd).style.display='block'; } function HideDetails(idd) { document.getElementById(idd).style.display='none'; } function FormatNumber(num, decimalPlaces, appendZeros, insertCommas) { var powerOfTen = Math.pow(10, decimalPlaces); var num1 = Math.round(num * powerOfTen) / powerOfTen; if (!appendZeros && !insertCommas) { return num1; } else { var strNum = num1.toString(); var posDecimal = strNum.indexOf("."); if (appendZeros) { var zeroToAppendCnt = 0; if (posDecimal < 0) { //strNum += "."; zeroToAppendCnt = decimalPlaces; } else { zeroToAppendCnt = decimalPlaces - (strNum.length - posDecimal - 1); } for (var i = 0; i < zeroToAppendCnt; i++) { strNum += "0"; } } if (insertCommas && (Math.abs(num) >= 1000)) { var j = strNum.indexOf("."); if (j < 0) { j = strNum.length; } j -= 3; while (j >= 1) { strNum = strNum.substring(0, j) + ',' + strNum.substring(j, strNum.length); j -= 3; } } return strNum; } } function IsDateTimeddmmyyyy(str) { mystring = str; if (mystring.match(/(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d/ ) ) { return true; } else { return false; } } function checkValidDate(strDate) { var regex = /^(((0[1-9]|[12]\d|3[01])\/(0[13578]|1[02])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|[12]\d|30)\/(0[13456789]|1[012])\/((1[6-9]|[2-9]\d)\d{2}))|((0[1-9]|1\d|2[0-8])\/02\/((1[6-9]|[2-9]\d)\d{2}))|(29\/02\/((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$/; if(!(regex.test(strDate))) { return false; } return true; } function validateDate(testdate) { var date_regex = /^(0[1-9]|1[0-2])\/(0[1-9]|1\d|2\d|3[01])\/(19|20)\d{2}$/ ; return date_regex.test(testdate); } function isInteger(s){ var i; for (i = 0; i < s.length; i++){ // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function stripCharsInBag(s, bag){ var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++){ var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); } function DaysArray(n) { for (var i = 1; i <= n; i++) { this[i] = 31 if (i==4 || i==6 || i==9 || i==11) {this[i] = 30} if (i==2) {this[i] = 29} } return this } function isDate(dtStr){ var dtCh= "/"; var minYear=1900; var maxYear=2100; var daysInMonth = DaysArray(12) var pos1=dtStr.indexOf(dtCh) var pos2=dtStr.indexOf(dtCh,pos1+1) var strDay=dtStr.substring(0,pos1) var strMonth=dtStr.substring(pos1+1,pos2) var strYear=dtStr.substring(pos2+1) strYr=strYear if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1) if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1) for (var i = 1; i <= 3; i++) { if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1) } month=parseInt(strMonth) day=parseInt(strDay) year=parseInt(strYr) if (pos1==-1 || pos2==-1){ //alert("Bạn hãy nhập ngày có định dạng : dd/mm/yyyy") return false } if (strMonth.length<1 || month<1 || month>12){ //alert("Bạn hãy nhập tháng") return false } if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){ //alert("Bạn hãy nhập ngày") return false } if (strYear.length != 4 || year==0 || yearmaxYear){ //alert("Bạn hãy nhập 4 số giữa "+minYear+" và "+maxYear) return false } if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){ //alert("Ban hay nhap ngay") return false } return true } function UpperTxt(ctl) { if(ctl!=undefined) { ctl.value=ctl.value.toUpperCase(); } } function UpperTextKeyUp(text) { try { text.value = text.value.toUpperCase(); } catch(err){} } function uppercaseText(objId) { var strIdcard=document.getElementById(objId); var xvalue=strIdcard.value; strIdcard.value=xvalue.toUpperCase(); } function CapitalizeFirstLetterInString(obj) { var strIdcard=document.getElementById(obj); var val=strIdcard.value; var newVal = ''; val = val.split(' '); for(var c=0; c < val.length; c++) { newVal += val[c].substring(0,1).toUpperCase() + val[c].substring(1,val[c].length) + ' '; } strIdcard.value = newVal; } function trim(str) { if (!str || typeof str != 'string') return null; return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' '); } function CreateGMessage(msgtype, msgtext) { $("#divmessage").attr("class", ""); if (msgtype == 1) { $("#divmessage").attr("class", "alert alert-info"); } else if (msgtype == 2) { $("#divmessage").attr("class", "alert alert-info"); } else if (msgtype == 3) { $("#divmessage").attr("class", "alert alert-success"); } else if (msgtype == 4) { $("#divmessage").attr("class", "alert alert-success"); } else { $("#divmessage").attr("class", "alert alert-info"); } $("#divmessage").text(msgtext); $('#divmessage').fadeIn(); } function ClearMessage() { $('#divmessage').fadeOut(); } function GetHeaderInvoice(){ var headerInv= "
"; headerInv += "
NGÂN HÀNG TMCP KIÊN LONG - KIENLONGBANK
"; headerInv += "
40 - 42 - 44 Phạm Hồng Thái, Rạch Giá, Kiên Giang
"; headerInv += "
ĐT: (077) 3869 950 - Fax: (077) - 3877 538
"; headerInv += "
Hotline: 1900 6929 - (08) 3933 9797
"; headerInv += "
"; return headerInv; }